package Work;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
    int[] array = {9,8,7,6,5,4,3,2,1};
        System.out.println(Arrays.toString(bubbleSort(array)));
    }

    public static int[] bubbleSort(int[] array) {
        for (int i = 0; i < array.length-1; i++) {
            for (int j = 1; j < array.length-i; j++) {
                if(array[j-1]>array[j]) {
                    array[j-1] ^= array[j];
                    array[j] ^= array[j-1];
                    array[j-1] ^= array[j];
                }
            }
        }
        return array;
    }
}
